﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AutoFacWrapper;
using ZL.WeChatCard.Entity;
using ZL.WeChatCard.Entity.EasyQuery;
using ZL.WeChatCard.Entity.EasyUse;
using ZL.WeChatCard.Entity.ViewModel;
using ZL.WeChatCard.Service;
using ZL.WeChatCard.Service.InterFace;

namespace ZLWeChatCard.Controllers
{
    /// <summary>
    /// 客户详情控制器
    /// </summary>
    public class CustomerDetailController : BaseController
    {
        public ActionResult Index()
        {
            // var openId = "omKGCt47hFZqzEQ-S0Fr0hI37G0U";
            var pservice = ClassFactory.GetInstance<IPaymentService>();
            AccInfo item = pservice.GetNo(OpenID);
            if (item == null)
            {
                return Redirect("~/Payment/Regesiter?act=Index&&contro=Charge");
            }
          
            var chargeInfo = pservice.GetAllAccInfo(OpenID);
            return View("CustomerDetail", chargeInfo);
        }


        public ActionResult IntegralDetail()
        {
            // var openId = "omKGCt47hFZqzEQ-S0Fr0hI37G0U";
            var pservice = ClassFactory.GetInstance<IPaymentService>();
            AccInfo item = pservice.GetNo(OpenID);
            if (item == null)
            {
                return Redirect("~/Payment/Regesiter?act=Index&&contro=Charge");
            }

            var accOprInfoService= ClassFactory.GetInstance<IEasyQueryService>();

            var info = accOprInfoService.GetJfChanges(OpenID);

            var infos=new List<AccOprInfo>();
            if (info != null)
            {
                infos.AddRange(info.AccOprInfos);
            }
            return View("IntegralDetail", infos);
        }


        public ActionResult TransactionDetail()
        {
            // var openId = "omKGCt47hFZqzEQ-S0Fr0hI37G0U";
            var pservice = ClassFactory.GetInstance<IPaymentService>();
            AccInfo item = pservice.GetNo(OpenID);
            if (item == null)
            {
                return Redirect("~/Payment/Regesiter?act=Index&&contro=Charge");
            }

            var accOprInfoService = ClassFactory.GetInstance<IEasyQueryService>();

            var info = accOprInfoService.GetBalanceChanges(OpenID);

            var infos = new List<AccOprInfo>();
            if (info != null)
            {
                infos.AddRange(info.AccOprInfos);
            }
            return View("TransactionDetail", infos);
        }

        public ActionResult CustomerInfo()
        {
            var pservice = ClassFactory.GetInstance<IEasyQueryService>();

       

            var item = pservice.GetCustInfoResponse(OpenID);
            if (item == null)
            {
                return Redirect("~/Payment/Regesiter?act=Index&&contro=Charge");
            }
          
           
            return View("CustomerInfo", item);
        }

        

    }


    

        
}